//格式时间戳
export function timestampToDateString(timestamp: number, format: string = 'yyyy-MM-dd HH:mm:ss'){
    const date = new Date(timestamp)

    const map: Map<string, number> = new Map()
    map.set("yyyy", date.getFullYear())
    map.set("MM", date.getMonth() + 1)
    map.set("dd", date.getDate())
    map.set("HH", date.getHours())
    map.set("mm", date.getMinutes())
    map.set("ss", date.getSeconds())

    return format.replace(/yyyy|MM|dd|HH|mm|ss/g, match => {
        const value = map.get(match)
        return value !== undefined ? String(value).padStart(2, '0') : match;
    })
}